package com.it.juxiang.demo.bool.Controller;

import com.it.juxiang.demo.bool.UserLoginLimiter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 模拟同一用户快速多次登录（请求），通过（UserLoginLimiter）限制
 *
 */


@Controller
public class UserLoginTimeController {
    @Autowired
    private UserLoginLimiter userLoginLimiter;




    @PostMapping("/bool")
    @ResponseBody
    public String test() {
        String ip="192.168.198.10";
        if (userLoginLimiter.check(ip)) {
            System.out.println(ip + ":访问成功：true...........！");
            return (ip + ":访问成功：true！");
        } else {
            System.out.println(ip +"：访问失败：false！");
            return (ip + "：访问失败：false！");
        }
    }

}
